import pymel as pm
import pantin
reload(pantin.node)


def testSetup () :
    nodeDict = {}
    nodeDict['character'] = pantin.node.CharacterNode('bobby_char01_pant',create=True,characterName='bobby')
    nodeDict['world'] = pantin.node.WorldNode('bobby_c_world01_pant',create=True,connectTo=nodeDict['character']+'.master_input')
    nodeDict['root'] = pantin.node.RootNode('bobby_c_root01_pant',create=True,connectTo=nodeDict['world']+'.master_input')
    nodeDict['r_hips'] = pantin.node.BoneNode('bobby_r_hips01_pant',create=True,connectTo=nodeDict['root']+'.right_input',side='r')
    nodeDict['l_hips'] = pantin.node.BoneNode('bobby_l_hips01_pant',create=True,connectTo=nodeDict['root']+'.left_input',side='l')
    nodeDict['r_leg'] = pantin.node.LegNode('bobby_r_leg01_pant',create=True,connectTo=nodeDict['r_hips']+'.master_input',twoJoints=True,side='r')
    nodeDict['l_leg'] = pantin.node.LegNode('bobby_l_leg01_pant',create=True,connectTo=nodeDict['l_hips']+'.master_input',twoJoints=False,side='l')
    nodeDict['r_foot'] = pantin.node.FootNode('bobby_r_foot01_pant',create=True,connectTo=nodeDict['r_leg']+'.master_input',side='r')
    nodeDict['l_foot'] = pantin.node.FootNode('bobby_l_foot01_pant',create=True,connectTo=nodeDict['l_leg']+'.master_input',side='l')
    nodeDict['spine'] = pantin.node.SpineNode('bobby_l_spine01_pant',create=True,connectTo=nodeDict['root']+'.master_input')
    nodeDict['r_clavicle_clav'] = pantin.node.ClavicleNode ('bobby_r_clavicle01_pant',create=True,connectTo=nodeDict['spine']+'.right_input',side='r')
    nodeDict['l_clavicle_clav'] = pantin.node.ClavicleNode ('bobby_l_clavicle01_pant',create=True,connectTo=nodeDict['spine']+'.left_input',side='l')
    nodeDict['r_arm'] = pantin.node.ArmNode('bobby_r_arm01_pant',create=True,connectTo=nodeDict['r_clavicle_clav']+'.master_input',side='r',twoJoints=True)
    nodeDict['r_hand'] = pantin.node.HandNode('bobby_r_hand01_pant',create=True,connectTo=nodeDict['r_arm']+'.master_input',side='r',fingerNumber=4)
    nodeDict['l_arm'] = pantin.node.ArmNode('bobby_l_arm01_pant',create=True,connectTo=nodeDict['l_clavicle_clav']+'.master_input',side='l',twoJoints=True)
    nodeDict['l_hand'] = pantin.node.HandNode('bobby_l_hand01_pant',create=True,connectTo=nodeDict['l_arm']+'.master_input',side='l',fingerNumber=4)
    nodeDict['neck'] = pantin.node.NeckNode('bobby_c_neck01_pant',create=True,connectTo=nodeDict['spine']+'.master_input')
    nodeDict['head'] = pantin.node.HeadNode('bobby_c_head01_pant',create=True,connectTo=nodeDict['neck']+'.master_input')
    
    #list = ['world','root','r_hips','l_hips','r_leg','l_leg','r_foot','l_foot','spine','r_clavicle_clav','l_clavicle_clav','r_arm','l_arm','neck','head','l_hand','r_hand']
    #list = ['world','root','r_hips','l_hips','r_leg','l_leg','r_foot','l_foot','spine','r_arm_simpleBone','l_arm_simpleBone']
    for node in nodeDict['character'].listChildNodes() :
        node.buildProxy()

    
    nodeDict['l_leg'].setTwoJoints(True)
    nodeDict['r_leg'].setTwoJoints(True)
        
    pantin.node.PantNode(nodeDict['neck'].proxy.listConnections()[0]).addMiddleControl()
    pantin.node.PantNode(nodeDict['neck'].proxy.listConnections()[0]).removeMiddleControl()
    
    #nodeDict['r_arm'].deleteProxy()
    #nodeDict['r_arm'].delete()
    
    #list = nodeDict['character'].getAllChildNodes()
    nodeDict['character'].updateAllProxy()
    
    pantin.node.PantNode(nodeDict['root'].proxy.listConnections()[0]).proxyBall.inputs()[0].translate.set(0,10,0)
    pantin.node.PantNode(nodeDict['l_hips'].proxy.listConnections()[0]).proxyBall.inputs()[0].translate.set(3,-1,0)
    pantin.node.PantNode(nodeDict['r_hips'].proxy.listConnections()[0]).proxyBall.inputs()[0].translate.set(-3,-1,0)
    
    #pantin.node.PantNode(nodeDict['world'].proxy.listConnections()[0]).buildSkeleton()
    #pantin.node.PantNode(nodeDict['root'].proxy.listConnections()[0]).buildSkeleton()
    #pantin.node.PantNode(nodeDict['l_hips'].proxy.listConnections()[0]).buildSkeleton()
    #pantin.node.PantNode(nodeDict['r_hips'].proxy.listConnections()[0]).buildSkeleton()
    #pantin.node.PantNode(nodeDict['r_leg'].proxy.listConnections()[0]).buildSkeleton()
    #pantin.node.PantNode(nodeDict['l_leg'].proxy.listConnections()[0]).buildSkeleton()
    #pantin.node.PantNode(nodeDict['r_foot'].proxy.listConnections()[0]).buildSkeleton()
    #pantin.node.PantNode(nodeDict['l_foot'].proxy.listConnections()[0]).buildSkeleton()
    #pantin.node.PantNode(nodeDict['spine'].proxy.listConnections()[0]).buildSkeleton()
